package ThreadDome;

public class Dome11 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()->{
            while (!Thread.currentThread().isInterrupted()) {
                System.out.println("hello thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    System.out.println("t线程被阻断");
                    break;
                }
            }
        });
        t.start();
        Thread.sleep(1000);
        t.interrupt();
        //t.interrupt();不会阻断正在运行的进程,但会改变阻塞状态
    }
}
